<template>
	<div class="my">
		<div class="graybg"></div>
		<img src="../assets/eachbg.png" class="top_img"/>
		<div class="top-h _width">
			<div class="top">
				<span>我的</span>
				<router-link :to="{name:'ishezhi'}">
					<i class="iconfont shezhi">&#xe609;</i>
				</router-link>
			</div>
			<!--名片-->
			<div class="card">
				<div class="container">
					<router-link :to="{name:'info'}">
						<img :src="u_img" class="tou" alt="" />
					</router-link>
					<p class="ming">
						{{name}}
						<span style="position: relative;">
							<img class="ziti" style="position: absolute;top: -45px;left: 28px;" src="../assets/ziti.png"/>
							<small style="margin-left: 10px;">{{level}}</small>
							<i v-for="leve in level"  class="iconfont">&#xe6d5;</i>
						</span>
					</p>
					<p class="system">系统编号：{{numbers}}</p>
					<p class="infos">
						<span class="span1">辅导员：{{coach}}</span>
						<span class="span2">服务中心：{{fuwu}}</span>
					</p>
				</div>
			</div>
		</div>

		<div class="center">
			<router-link :to="{name:'renzheng'}">
				<section>
					<p class="pull-left">
						<i class="iconfont">&#xe619;</i>
						<span>实名认证</span>
					</p>
					<p class="pull-right">
						<span class="renzheng">{{attestation}}</span>
						<i class="iconfont">&#xe615;</i>
					</p>
				</section>
			</router-link>
			<router-link :to="{name:'fudao'}">
				<section>
					<p class="pull-left">
						<i class="iconfont">&#xe611;</i>
						<span>我的辅导店铺</span>
					</p>
					<p class="pull-right">
						<i class="iconfont">&#xe615;</i>
					</p>
				</section>
			</router-link>
			<router-link :to="{name:'yijian'}">
				<section>
					<p class="pull-left">
						<i class="iconfont">&#xe657;</i>
						<span>意见反馈</span>
					</p>
					<p class="pull-right">
						<i class="iconfont">&#xe615;</i>
					</p>
				</section>
			</router-link>
			<section @click="fuwuCenter">
				<p class="pull-left">
					<i class="iconfont">&#xe60c;</i>
					<span>我的服务中心</span>
				</p>
				<p class="pull-right">
					<i class="iconfont">&#xe615;</i>
				</p>
			</section>
		</div>
		<!--底部-->
		<tab></tab>
	</div>
</template>
<script>
	import tab from './table.vue';
	export default {
		components:{tab},
		data() {
			return {
				u_img:"",//用户头像
				numbers:"",//编号
				coach:"",//辅导员
				attestation:"",//实名认证=》认证情况
				name:"",	//用户名称
				level:{},	//用户等级
				fuwu:"",	//服务中心
				
				status:'',	//判断我的服务中心进入那一页
			}
		},
		mounted: function() {
			//获取用户的信息
			var params = new URLSearchParams();
			var info = window.localStorage.data;
			if(info == undefined){
				this.$router.push("wlogin");
			}else{
				this.$axios.get('One/My/index/token/' + info).then((res) => {
					if(res.data.status == 1) {
						var datas = res.data;
						this.u_img = datas.data.u_img;
						this.numbers = datas.data.u_invite;
						this.attestation = datas.data.u_real;
						this.name = datas.data.u_name;
						this.level = Number(datas.data.u_level);
						if(datas.data.u_servicec == null){//服务中心
							this.fuwu = "--";
						}else{
							this.fuwu = datas.data.u_servicec;
						};
						
						if(datas.data.u_pid == null){	//辅导员
							this.coach = "--"
						}else{
							this.coach = datas.data.u_pid;
						}
					}else if(res.data.status == 0){
						alert("获取失败")
					}else if(res.data.status == 2){
						alert("参数错误")
					}
				}).catch((err) => {
					console.log(err)
				});
				
				//判断我的服务中心
				this.$axios({
				   url:"One/My/myServeC/token/"+info,
					method:"get",
					data:params
				  }).then((res)=>{
						this.status = res.data.status;		
				}).catch(function(err){
					console.log(err)		
				})
					
			}
		},
		methods: {
			//我的服务中心根据审核情况跳转不同的页面
			fuwuCenter:function(){
				if(this.status == 0){	
					this.$router.push({name: 'kongfuwu'});
				}
				else if(this.status == 1){
					this.$router.push({name: 'shenhesuccess'});
				}
				else if(this.status == 2){
					this.$router.push({name: 'shenhefail'});
				}
			}
		}
	}
</script>

<style scoped="scoped">
	@import "../css/public.css";
	@import "../css/imy.css";
	.ming span .ziti {
		width: 19px;
		height: 17px;
		margin-top: 50px;
	}
	
	.bg {
		position: fixed;
		width: 100%;
		height: 100%;
		z-index: -1;
		background: #f0f0f0;
	}
	.top_img{
		position: fixed;
		z-index: -1;
		width: 100%;
		height: 237px;
	}
	.top-h {
		height: 260px;
		font-size: 18px;
	}
	
	.top {
		line-height: 42px;
		color: #fff;
		overflow: hidden;
		text-align: center;
		position: relative;
	}
	
	.top span {
		position: relative;
	}
	
	.top .shezhi {
		font-size: 18px;
		position: absolute;
		right: 16px;
	}
	
	.top a {
		color: #fff;
	}
</style>